summon armor_stand ~ ~ ~ {Tags:[tempDaggerAttribute],Invisible:true,Invulnerable:true,Marker:true}

item replace entity @n[tag=tempDaggerAttribute,distance=..30,type=armor_stand] weapon.mainhand from entity @s weapon.mainhand
data modify entity @n[tag=tempDaggerAttribute,distance=..30,type=armor_stand] HandItems[0].components."minecraft:custom_data".powerSwordAttribute set from entity @n[tag=tempDaggerAttribute,distance=..30,type=armor_stand] HandItems[0].components."minecraft:attribute_modifiers"
item replace entity @s weapon.mainhand from entity @n[tag=tempDaggerAttribute,distance=..30,type=armor_stand] weapon.mainhand

item modify entity @s weapon.mainhand vs:dagger

kill @n[tag=tempDaggerAttribute,distance=..30,type=armor_stand]